﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TLECDataLayer;

namespace CreateReservations
{
    public partial class PurchaseCreated : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int tmp;
            if (Request.Params["resId"] != null && int.TryParse(Request.Params["resId"], out tmp))
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            Reservation r = Reservations.GetReservationById(Convert.ToInt32(Request.Params["resId"]));
            this.resIdLbl.Text = "Your purchase number: " + r.ReservationId.ToString();
            this.nameLbl.Text = "Your name: " + Server.HtmlEncode(r.CustomerName);
            this.numLbl.Text = "Number of tickets: " + r.NumberOfTickets.ToString();
            this.addLbl.Text = "Your address: " + Server.HtmlEncode(r.ShippingAddress);
            this.eveLbl.Text = "Event title: " + Server.HtmlEncode(r.Event.Title);
            this.statusLbl.Text = "Purchase status: " + Server.HtmlEncode(r.ReservationStatuse.StatusName);
            this.dateLbl.Text = "Purchase date and time: " + r.PurchaseDate.ToString();
            this.totalPLbl.Text = string.Format("Total price: {0:c}", r.NumberOfTickets * r.Event.Price);
        }
    }
}